﻿using System;

public class Mapper072 : MapperDefault
{
    public override void init(NES nes)
    {
        base.init(nes);
    }

    public override void loadROM(ROM rom)
    {
        if (!rom.Valid)
        {
            Console.Out.WriteLine("048: Invalid ROM! Unable to load.");
        }
        else
        {
            int num = rom.RomBankCount * 2;
            this.loadRomBank(1, 0x8000);
            this.loadRomBank(num - 1, 0xc000);
            this.loadCHRROM();
            base.nes.Cpu.requestIrq(2);
        }
    }

    public override void write(int address, short value_Renamed)
    {
        if (address < 0x8000)
        {
            base.write(address, value_Renamed);
        }
        else
        {
            int num = value_Renamed & 15;
            int romBankCount = base.rom.RomBankCount;
            if ((value_Renamed & 0x80) != 0)
            {
                this.loadRomBank(num * 2, 0x8000);
                this.loadRomBank(romBankCount - 1, 0xc000);
            }
            if ((value_Renamed & 0x40) != 0)
            {
                this.load8kVromBank(num * 8, 0);
            }
        }
    }
}

